package com.study.meituan.adapter;

import java.util.List;

import com.study.meituan.R;
import com.study.meituan.entity.CaiDanItemEntity;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView.FindListener;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class CaiDanItemAdapter extends BaseAdapter {
	private Context context;
	private LayoutInflater inflater;
	private List<CaiDanItemEntity> mlist;
	private int selectedPosition = 0;
	

	public CaiDanItemAdapter(Context context, List<CaiDanItemEntity> mlist) {
		
		this.context = context;
		this.mlist = mlist;
		inflater=LayoutInflater.from(context);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mlist.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
	
		
		convertView=inflater.inflate(R.layout.cai_dan_item, null);
		ImageView a=(ImageView)convertView.findViewById(R.id.img);
		a.setBackgroundResource(mlist.get(position).getImg());
		TextView b=(TextView)convertView.findViewById(R.id.name);
		b.setText(mlist.get(position).getName());
		
		TextView c=(TextView)convertView.findViewById(R.id.num_month);
		c.setText(mlist.get(position).getNum_month());
		TextView d=(TextView)convertView.findViewById(R.id.favor);
		d.setText(mlist.get(position).getFavor());
		TextView e=(TextView)convertView.findViewById(R.id.price);
		e.setText(mlist.get(position).getPrice());
		
		return convertView;
	}

}
